#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
当当网商品爬虫运行脚本
"""

import os
import sys
from scrapy.cmdline import execute

def main():
    """主函数"""
    # 设置项目路径
    project_path = os.path.dirname(os.path.abspath(__file__))
    os.chdir(project_path)
    
    # 运行爬虫
    try:
        print("开始运行当当网商品爬虫...")
        execute(['scrapy', 'crawl', 'dangdang_products'])
        print("爬虫运行完成！")
    except Exception as e:
        print(f"爬虫运行出错: {e}")
        sys.exit(1)

if __name__ == "__main__":
    main() 